package org.lanqiao.servlet;

import java.io.IOException;
import java.sql.SQLException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import static org.lanqiao.tools.DBTools.*;

@WebServlet("/DeleteStuentById")
public class DeleteStuentById extends HttpServlet {
	@Override
	protected void service(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		request.setCharacterEncoding("utf-8");
		response.setCharacterEncoding("utf-8");
		super.service(request, response);
	}
	
	
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		String id=req.getParameter("id");
		try {
			int i = query.update("delete from student where id=?",id);
			if (i>0) {
				resp.getWriter().write("OKOKOK!!!");
			}else {
				resp.getWriter().write("NONONO!!!");
			}
		} catch (SQLException e) {
			e.printStackTrace();
		}
		
	}
}










